package com.mine.redis.util.mapper;

import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author weixiao
 * @date 2024/8/19 10:21
 */
@Mapper
public interface FollowMapper {

    @Insert("insert into t_follow(user_id, follow_id, create_time) values (#{userId}, #{followId}, now())")
    int insert(@Param("userId") Integer userId, @Param("followId") Integer followId);

    @Delete("delete from t_follow where user_id = #{userId} and follow_id = #{followId}")
    int delete(@Param("userId") Integer userId, @Param("followId") Integer followId);

    @Select("select count(*) from t_follow where user_id = #{userId} and follow_id = #{followId}")
    int isFollow(@Param("userId") Integer userId, @Param("followId") Integer followId);

    @Select("select user_id from t_follow where follow_id = #{followId}")
    List<Integer> getFans(@Param("followId") Integer followId);
}
